import numpy as np
import random as rd


def loadDataSet(fileName):
    dataMat = []
    labelMat = []
    fr = open(fileName)
    for line in fr.readlines():
        lineArr = line.strip().split('\t')
        dataMat.append([float(lineArr[0]), float(lineArr[1])])
        labelMat.append(float(lineArr[2]))
    return dataMat, labelMat


def selectJrand(i, m):
    j = i
    while (j == i):
        j = int(rd.random.uniform(0, m))
    return j            # return a int which is not equal with i


def clipAlpha(aj, H ,L):
    if aj > H:
        aj = H
    if L > aj:
        aj = L
    return aj           # make H <= aj <= L


def smoSimple(dataMatIn, classLabels, C, toler, maxIter):
    dataMatrix = np.array(dataMatIn)
    labelArray = np.array(classLabels).reshape(100,1)
    b = 0
    m, n = np.shape(dataMatrix)
    alphas = np.array(np.zeros(m, 1))


if __name__ == '__main__':
    dataMat , labelMat = loadDataSet("./testSet.txt")
    smoSimple(dataMat, labelMat, 0, 0, 0)

